﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ongoal.Quotation.Http
{
    /// <summary>
    /// 内容类型
    /// </summary>
    public enum ContentType
    {
        /// <summary>
        /// XML
        /// </summary>
        Xml,
        /// <summary>
        /// JSON
        /// </summary>
        Json,
        /// <summary>
        /// 文本
        /// </summary>
        Text,
        /// <summary>
        /// 表单数据
        /// </summary>
        XwwwFormUrlEncoded
    }

    /// <summary>
    /// 
    /// </summary>
    public static class ContentTypeEx
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contentType"></param>
        /// <returns></returns>
        public static string ConvertToString(this ContentType contentType)
        {
            switch (contentType)
            {
                case ContentType.Json:
                    return "application/json";
                case ContentType.Xml:
                    return "application/xml";
                case ContentType.Text:
                    return "application/text";
                case ContentType.XwwwFormUrlEncoded:
                    return "application/text";
                default:
                    return "application/json";
            }
        }
    }
}
